package com.example.aslongastoday.db.dao;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;

import com.example.aslongastoday.domain.BackLog;
import com.example.aslongastoday.domain.BackLogGroup;

import junit.framework.TestCase;

import java.util.List;

public class BackLogGroupDaoTest extends TestCase {

    public void testUpdate() {
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        BackLogGroupDao dao = BackLogGroupDao.getInstance(appContext);
        List<BackLogGroup> backLogGroups = dao.queryUnfinishedAll();
        BackLogGroup backLogGroup = backLogGroups.get(3);
        backLogGroup.setGroupName("这是修改后的组名称");
        //修改名称
        dao.update(backLogGroup);

        List<BackLogGroup> backLogGroups1 = dao.queryUnfinishedAll();

        BackLogGroup backLogGroup1 = backLogGroups1.get(3);
        List<BackLog> backLogList = backLogGroup1.getBackLogList();
        BackLog backLog = backLogList.get(1);
        backLog.setStatus(0);
        backLog.setContent("我是修改后的待办");
        dao.update(backLogGroup1);

        List<BackLogGroup> backLogGroups2 = dao.queryUnfinishedAll();

        System.out.println("成功修改");
    }


    public void testDelete() {
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        BackLogGroupDao dao = BackLogGroupDao.getInstance(appContext);

        List<BackLogGroup> backLogGroups = dao.queryUnfinishedAll();

        dao.delete(2);

        List<BackLogGroup> backLogGroups1 = dao.queryUnfinishedAll();

        System.out.printf("删除成功");

    }

    public void testQuery(){
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        BackLogGroupDao dao = BackLogGroupDao.getInstance(appContext);
        List<BackLogGroup> backLogGroups = dao.queryAll();
        System.out.println();
    }
}